package com.rmkj.trade.match.core.ob;

import java.util.Observable;

/**
 * Created by Administrator on 2019/1/11.
 */
public class ChangeObservable<T extends ChangeData> extends Observable {

	private Changeable<T> changeable;

	private T data;

	public T getData() {
		return data;
	}

	public void setChangeable(Changeable<T> changeable){
		this.changeable = changeable;
	}

	public void setData(T data) {
		if (data != null
				&& (this.data == null || changeable.isChanged(this.data, data))) {
			this.data = data;
			setChanged();
			notifyObservers();
		}
	}

	public void initData(T data){
		if (this.data == null)	this.data = data;
	}

}
